package com.sos.controller;

import com.sos.model.dto.HealthProfileDTO;
import com.sos.model.dto.HealthProfileUpdateDTO;
import com.sos.model.vo.ResultVO;
import com.sos.service.HealthProfileService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.security.SecurityRequirement;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/health-profile")
@RequiredArgsConstructor
@Tag(name = "健康档案", description = "健康档案相关接口")
@SecurityRequirement(name = "bearerAuth")
public class HealthProfileController {

    private final HealthProfileService healthProfileService;

    @PostMapping
    @Operation(summary = "创建或更新健康档案", description = "创建或更新当前用户的健康档案")
    public ResultVO<HealthProfileDTO> saveOrUpdateHealthProfile(@RequestBody HealthProfileUpdateDTO healthProfileUpdateDTO) {
        return healthProfileService.saveOrUpdateHealthProfile(healthProfileUpdateDTO);
    }

    @GetMapping
    @Operation(summary = "获取当前用户健康档案", description = "获取当前用户的健康档案信息")
    public ResultVO<HealthProfileDTO> getCurrentUserHealthProfile() {
        return healthProfileService.getCurrentUserHealthProfile();
    }

    @GetMapping("/{userId}")
    @Operation(summary = "根据用户ID获取健康档案", description = "根据用户ID获取指定用户的健康档案信息")
    public ResultVO<HealthProfileDTO> getHealthProfileByUserId(@PathVariable Long userId) {
        return healthProfileService.getHealthProfileByUserId(userId);
    }
}